package com.ruoyi.patrol.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.patrol.domain.PtFormDetails;
import com.ruoyi.patrol.service.IPtFormDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单详情Controller
 * 
 * @author lkm
 * @date 2022-11-12
 */
@RestController
@RequestMapping("/patrol/details")
public class PtFormDetailsController extends BaseController
{
    @Autowired
    private IPtFormDetailsService ptFormDetailsService;

    /**
     * 查询单详情列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtFormDetails ptFormDetails)
    {
        startPage();
        List<PtFormDetails> list = ptFormDetailsService.selectPtFormDetailsList(ptFormDetails);
        return getDataTable(list);
    }

    /**
     * 导出单详情列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:details:export')")
    @Log(title = "单详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PtFormDetails ptFormDetails)
    {
        List<PtFormDetails> list = ptFormDetailsService.selectPtFormDetailsList(ptFormDetails);
        ExcelUtil<PtFormDetails> util = new ExcelUtil<PtFormDetails>(PtFormDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取单详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ptFormDetailsService.selectPtFormDetailsById(id));
    }

    /**
     * 修改单详情
     */
    @PreAuthorize("@ss.hasPermi('patrol:details:edit')")
    @Log(title = "单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtFormDetails ptFormDetails)
    {
        return toAjax(ptFormDetailsService.updatePtFormDetails(ptFormDetails));
    }

    /**
     * 删除单详情
     */
    @PreAuthorize("@ss.hasPermi('patrol:details:remove')")
    @Log(title = "单详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptFormDetailsService.deletePtFormDetailsByIds(ids));
    }
}
